/*
package com.lzy.interceptor;

import com.google.gson.Gson;
import com.lzy.model.RestResponseResult;
import com.lzy.util.IpUtils;
import com.lzy.util.ResultThreadLocalUtil;
import com.lzy.util.ThreadLocalUtil;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
import java.util.UUID;

*/
/**
 * @author lzy by 2019/9/10 17:26
 *//*

@Slf4j
public class LogInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
        ThreadLocalUtil.remove();
        MDC.put("requestId", getRequestId(request));
        log.info("----------,{},----------", request.getRequestURI());
        log.info("请求IP地址:{}", IpUtils.getIpAddress(request));
        log.info("客户端信息:{}", request.getHeader("user-agent"));
        String authorization = "Authorization";
        log.info("客户端Authorization:{}", request.getHeader(authorization));
        log.info("请求的参数如下:");
        Map<String, String[]> requestData = request.getParameterMap();
        for (Map.Entry<String, String[]> entry : requestData.entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();
            log.info("{}-->{}", key, value);
        }

        return Boolean.TRUE;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {

    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
        RestResponseResult restResponseResult = ResultThreadLocalUtil.getRestResponse();
        String s = new Gson().toJson(restResponseResult);
        log.info("Results--->{}", s);
        ThreadLocalUtil.remove();
    }

    private String getRequestId(HttpServletRequest request) {
        String uuid = request.getHeader("uuid");
        if (StringUtils.isEmpty(uuid)) {
            uuid = UUID.randomUUID().toString().replaceAll("-", "");
        }
        return uuid;

    }


}
*/
